package tgt

import "fmt"

func installCommand(tgtIniFile, tgtYamlFile string) string {
	//execHeader := "sh -c"
	cdDir := "cd " + ansible_dir
	installTgt := fmt.Sprintf("ansible-playbook %s/%s -i %s/%s --tags tgt_install", ansible_dir, tgtYamlFile, ansible_dir, tgtIniFile)
	return fmt.Sprintf("%s && %s", cdDir, installTgt)
}

func uninstallCommand(tgtIniFile, tgtYamlFile string) string {
	//execHeader := "sh -c"
	cdDir := "cd " + ansible_dir
	uninstallTgt := fmt.Sprintf("ansible-playbook %s/%s -i %s/%s --tags tgt_uninstall", ansible_dir, tgtYamlFile, ansible_dir, tgtIniFile)
	return fmt.Sprintf("%s && %s", cdDir, uninstallTgt)
}

func addTargetCommand(tgtIniFile, tgtYamlFile string) string {
	cdDir := "cd " + ansible_dir
	addTarget := fmt.Sprintf("ansible-playbook %s/%s -i %s/%s --tags add_target", ansible_dir, tgtYamlFile, ansible_dir, tgtIniFile)
	return fmt.Sprintf("%s && %s", cdDir, addTarget)
}

func removeTargetCommand(tgtIniFile, tgtYamlFile string) string {
	cdDir := "cd " + ansible_dir
	addTarget := fmt.Sprintf("ansible-playbook %s/%s -i %s/%s --tags remove_target", ansible_dir, tgtYamlFile, ansible_dir, tgtIniFile)
	return fmt.Sprintf("%s && %s", cdDir, addTarget)
}

func addLUNCommand(tgtIniFile, tgtYamlFile string) string {
	cdDir := "cd " + ansible_dir
	addLUN := fmt.Sprintf("ansible-playbook %s/%s -i %s/%s --tags add_lun", ansible_dir, tgtYamlFile, ansible_dir, tgtIniFile)
	return fmt.Sprintf("%s && %s", cdDir, addLUN)
}

func bindIPCommand(tgtIniFile, tgtYamlFile string) string {
	cdDir := "cd " + ansible_dir
	addLUN := fmt.Sprintf("ansible-playbook %s/%s -i %s/%s --tags add_ipbind", ansible_dir, tgtYamlFile, ansible_dir, tgtIniFile)
	return fmt.Sprintf("%s && %s", cdDir, addLUN)
}

func bindUserCommand(tgtIniFile, tgtYamlFile string) string {
	cdDir := "cd " + ansible_dir
	addLUN := fmt.Sprintf("ansible-playbook %s/%s -i %s/%s --tags target_binduser", ansible_dir, tgtYamlFile, ansible_dir, tgtIniFile)
	return fmt.Sprintf("%s && %s", cdDir, addLUN)
}

func cleanTmpfileCommand(filename string) string {
	mvFile := "mv %s/%s %s/%s"
	return fmt.Sprintf(mvFile, ansible_dir, filename, tmp_dir, filename)
}

func showTgtStatusCommand() string {
	return "systemctl show tgt"
}
